package Web;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author wuhan
 * @date 2019/10/17 14:46
 */

class TcpClient{
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("172.20.10.11",10003);
        OutputStream outputStream = s.getOutputStream();
        outputStream.write("tcp ge men laile".getBytes());
        s.close();
    }
}


class ServerDemo{
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10003);
        Socket accept = ss.accept();
        InputStream inputStream = accept.getInputStream();
        byte[] buf = new byte[1024];
        int len = inputStream.read(buf, 0, buf.length);
        System.out.println(new String(buf,0,len));
        String hostAddress = accept.getInetAddress().getHostAddress();
        System.out.println(hostAddress);
        accept.close();
        ss.close();

    }
}



public class TcpDemo1 {
    public static void main(String[] args) {

    }
}
